﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace HDJ.Framework.Core {
    public class LogItems : MonoBehaviour
    {
        public Image Image_Head;
        public Text Text_Content;
        private Image bg;
        private LogWindow logWindow;
        // Start is called before the first frame update
        public void Init()
        {
            bg = GetComponent<Image>();
        }
        public LogInfo logInfo;
        public void Show(LogWindow logWindow, LogInfo logInfo)
        {
            this.logWindow = logWindow;
            this.logInfo = logInfo;
            string color = "red";
            switch (logInfo.logType)
            {
                case LogType.Error:
                    
                case LogType.Assert:
                case LogType.Exception:
                    Image_Head.color = Color.red;
                    color = "red";
                    break;
                case LogType.Warning:
                    color = "orange";
                    Image_Head.color = Color.yellow;
                    break;
                case LogType.Log:
                    color = "black";
                    Image_Head.color = Color.black;
                    break;
               
            }
            string message = string.Format("<color={0}>{1}</color>", new object[] { color, logInfo.ToString() });
            Text_Content.text = message;

            bg.color = logInfo.index % 2 == 0 ? Color.white : new Color(212/255f,212/255f,212/255f,1);
        }
        public void OnButtonClick()
        {
            logWindow.ShowDetailLog(logInfo);
        }
    }
}
